const connect = (root) => {
  let queue = []
  if(root) {
    queue.push(root)
  }
  while(queue.length > 0) {
    let l = queue.length
    //根据队列的特性，先进先出
    let node = queue.shift()
    //如果队列中还有元素的话说明一定有next
    if(l>0) node.next = queue[0]
    node.left && queue.push(node.left)
    node.right && queue.push(node.right)
  }
}